package com.grape.dp.singleton.懒汉式;

/**
 * 描述:SingletonV2Test
 * @author: myx
 * @date: 2019/7/29 0029
 * Copyright © 2019-grape. All rights reserved.
 */
public class SingletonV2Test {
    public static void main(String[] args) {
        // 如何去模拟高并发情况下 懒汉式线程安全问题
        for (int i = 0; i < 10; i++) {
            new Thread(new Runnable() {
                public void run() {
                    SingletonV2 singletonV1 = SingletonV2.getSingletonV2();
                    System.out.println(Thread.currentThread().getName() + "," + singletonV1);
                }
            }).start();
        }
    }
}
